var vm=new Vue({
    el:"#doctor",
    data: {
        doctorList:[],
        doctorCategory:"",
        doctor:{}
    },
    mounted(){
        this.getPageData();
    },
    methods: {
        //根据医生类型查询医生
        selectByDoctorCategory:function (doctorCategory){
            let that=this;
            axios.get("/doctor/selectByDoctorCategory.do?doctorCategory="+doctorCategory).then(function (response){
                that.doctorList=response.data;
                that.doctorCategory=doctorCategory;
            }).catch(function (error) {
                console.log(error);
            });
            /*for (let i=0;i<that.doctorList.length;i++){
                that.doctorList[i].headPortrait=require('that.doctorList[i].headPortrait');
                console(that.doctorList[i].headPortrait);
            }*/
        },
        //根据指定索引查看医生详情信息
        findId:function (i) {
            this.doctor = this.doctorList[i];
            //将数据暂存入本地缓存
            localStorage.setItem('this.doctor',JSON.stringify(this.doctor));
            localStorage.setItem('this.doctorCategory',this.doctorCategory);
        },
        //刷新页面或者从别的页面进入，提取this.doctor的值
        getPageData:function() {
            //从本地缓存中取数据
            this.doctor = JSON.parse(localStorage.getItem('this.doctor'));
            this.doctorCategory=localStorage.getItem('this.doctorCategory');
            if(this.doctor==null){
                this.doctor={}
            }
        },
        //清除本地缓存
        clearDoctorData:function (){
            localStorage.clear();
        }
    }

})